package com.hspud.enum_.HomeWorrk06;

public class Person {
    private String name;
    private Vehicles vehicles;

    public Person(String name, Vehicles vehicles) {
        this.name = name;
        this.vehicles = vehicles;
    }
    public void passRiver(){
       if(!(vehicles instanceof Boat)){
           vehicles = VehiclesFactory.getBoat();
       }
        vehicles.work();
    }
    public void common(){
       if(vehicles == null ){
           vehicles = VehiclesFactory.getHouse();
       }
       vehicles.work();
    }
    public void passMount(){
        if(vehicles instanceof Boat){
            vehicles = VehiclesFactory.getFly();
        }
        vehicles.work();
    }
}
